<?php
/*
	Copyright (C) 2008 - 2012 Inanta Martsanto
	Inanta Martsanto (inanta@inationsoft.com)

	This file is part of NewStep Framework.

	NewStep Framework is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	NewStep Framework is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with NewStep Framework.  If not, see <http://www.gnu.org/licenses/>.
*/

namespace Inationsoft\NS\Template;

use Inationsoft\NS\Object;

define('NS_TPL_PHP', 'php');
define('NS_TPL_SMARTY', 'smarty');

/**
 *Template base class
 *
 *@author Inanta Martsanto <inanta@inationsoft.com>
 */
abstract class Template extends Object {
	static private $_lastInstance = null;
	static private $_enginesInstance = array();

	static function getInstance($tpl_type = NS_TPL_PHP, $args = array()) {
		if(self::$_lastInstance == null) self::$_lastInstance = $tpl_type;
		if(isset(self::$_enginesInstance[$tpl_type])) return self::$_enginesInstance[$tpl_type];

		switch(self::$_lastInstance) {
			case NS_TPL_SMARTY:
				return (self::$_enginesInstance[NS_TPL_SMARTY] = new Engine\SmartyTemplate($args));
				break;
			case NS_TPL_PHP:
			default:
				return (self::$_enginesInstance[NS_TPL_PHP] = new Engine\PHPTemplate($args));
		}
	}

        function __construct($args) {
                $this->createProperties(array('Path' => '', 'File' => ''));
        }
}
?>